Identifying A Disk Volume

Each volume, or disk partition, has a device entry associated with it.  To make an disk image using Unix tools that aren't Mac-specific, or to make an image on an unmounted volume, you will need to know that device ID.  These instructions show you two ways to do that, and then tell you what it means:

Using the GUI

Fire up Disk Utility.  [1]. Select your volume and [2] hit the "Info" button (or press Cmd-I).  You'll see the crucial information as [3] 'Disk Identifier'.

Here we see that "Macintosh HD" is "disk0s2".  (See below for what that means).

6a0fa243-a842-41da-be6a-8443a3d3a8ff.png


Using the Command Line

Open up Terminal.app.  Type in the command "diskutil list".

Here we can see that the device associated with "Macintosh HD" is "disk0s2".

94258411-82ef-4010-81b4-27e49e98ada9.png


What does it mean?

So, we found out that "Macintosh HD" is "disk0s2".  What does that mean?

The short explanation is it means unix tools to access the device as "/dev/rdisk0s2".  (You do need to unmount the device first, though).

As for a longer explanation:

  • There is a /dev folder on the directory tree with "files" that represent devices.
  • The image below shows a listing of all file entries in the /dev folder with 'disk' in the name.
  • /dev/disk0 is the primary hard drive.  
    • (/dev/disk1, /dev/disk2, /dev/disk3, etc. would represent other drives -- be they hard drives, network shares, SD cards, RAM disks, mounted disk images, or so on).
  • The disk is divided into "slices" (partitions/volumes):
    • /dev/disk0s1 (slice 1 of disk 0) is (from the previous picture) of type EFI and contains information to boot the system up.
    • /dev/disk0s2 (slice 2 of disk 0) is "Macintosh HD"; the type Apple_HFS and is a standard Macintosh hard drive volume.
    • /dev/disk0s3 (slice 3 of disk 0) is "Recovery HD"; the recovery partition is standard, but hidden by setting the type to Apple_Boot.
  • Note that everything shows up twice, just slightly differently.
    • There is an entry called /dev/disk0s2 with a type of 'b' (the first symbol on the line) -- it is a block device.
    • There is also a 'raw' entry called /dev/rdisk0s2, with a type of 'c' -- it is called a character device.
    • You have to read and write to the raw devices in 4k chunks of data, whereas the non-raw device uses buffered I/O and you can read or write a single byte at a time and the operating system makes it work for you.
    • Working with the raw devices is usually faster when reading or writing the whole thing.
      • Therefore, I recommend expanding "disk0s2" to "/dev/rdisk0s2".
    • [I find it confusing that we seem to read and write blocks of data to a character device.  Thinking of it as a raw, or unbuffered, device makes more sense to me.]

9718872a-00f9-4f6a-8b90-85fe022676d9.png


Back to: Creating A Raw Disk Image